/**
 * 文章基本信息表
 *
 */
module.exports = app => {
	const { STRING, INTEGER, CHAR, Sequelize } = app.Sequelize;
	const Skills = app.model.define(
		'skills',
		{
			skillId: {
				type: INTEGER,
				primaryKey: true,
				autoIncrement: true,
				field: 'skill_id'
			},
			//文章标题
			skillTitle: {
				type: STRING(100),
				notNull: true,
				field: 'skill_title'
			},
			//文章副标题
			subTitle: {
				type: STRING(100),
				notNull: true,
				field: 'sub_title'
			},
			// 文章类型
			skillType: {
				type: Sequelize.INTEGER(2),
				field: 'skill_type'
			},
			// 文章创建时间
			createTime: {
				type: Sequelize.DATE,
				defaultValue: Sequelize.NOW,
				field: 'create_time'
			},
			// 文档更新时间
			updateTime: {
				type: Sequelize.DATE,
				defaultValue: Sequelize.NOW,
				field: 'update_time'
			},
			// 文章的图片
			skillPic: {
				type: STRING(200),
				field: 'skill_pic'
			},
			// 文档作者id
			skillAuthor: {
				type: STRING(50),
				field: 'skill_author'
			},
			// 是否显示
			isShow: {
				type: Sequelize.CHAR(1),
				defaultValue: 0, // 默认不显示,
				field: 'is_show'
			},
			// 是否置顶
			isTop: {
				type: Sequelize.CHAR(1),
				defaultValue: 0, // 默认不置顶,
				field: 'is_top'
			},
			// 是否存在图片
			isPicArcticle: {
				type: Sequelize.CHAR(1),
				field: 'is_pic_arcticle'
			},
			// 内容
			skillContent: {
				type: Sequelize.STRING(5000),
				field: 'skill_content'
			}
		},
		{
			timestamps: false, //去除createAt updateAt
			freezeTableName: true //使用自定义表名
		}
	);

	Skills.associate = function() {
		app.model.Skills.hasMany(app.model.SkillType, { foreignKey: 'skillId', targetKey: 'skillId' });
	};
	return Skills;
};
